<?php 
if(!isset($comment)) $comment=$this->Comment;
if(!isset($javascript)) $javascript=$this->Javascript;
if(!isset($html)) $html=$this->Html;
?>
<table cellspacing='0' cellpadding='0' class='minuteitem' id='minuteitem_<?php echo $node;?>' width='100%'>
    <tr>
        <td valign="top" class="minuteitem_number"><?php echo $numbering[0];?></td>
        <td>&nbsp;</td>
        <td colspan='5' valign="top" class="minuteitem_item">
            
            <?php if ( isset($report) != 1 ) {  ?>            
                <div id='displayminute_<?php echo $node;?>'>
            <?php } ?>
            <?php echo $decision['Decision']['description'];?>
            <?php if ( isset($report) != 1 ) {  ?>
                </div>
            <?php } ?>
            <?php
            if (isset($decision['0'])) {
                $num_attach = count($decision['0']);
                echo "<span class='attachment'>".__('Attachments',true).":</span> ";
                for ($i=0;$i<$num_attach;$i++) {
                    echo "<span id='att2".$decision['0'][$i]['id']."'><a href='../../../".$decision['0'][$i]['file']."'>".$decision['0'][$i]['filename']."</a></span>";
                    if($decision['0'][$i]['private']){
                        echo "<img src='".router::url('/img/icons/lock.png')."' alt='".__('Private',true)."'/>";
                    }
                    if ($i < $num_attach-1) {
                        echo ", ";
                    }
                }
            }
            ?>
        </td>
        <?php if($this->params['action']=='printminutes' && (!empty($chairperson)||!empty($isSec) || $permission['Minute approval']['Create']) && empty($minutes_approved) ){?>
            <td>&nbsp;</td>
            <td  class='minutecomment'>
                <?php 
                    if(isset($javascript)){
                        if(!empty($chairperson) || $permission['Minute approval']['Create']){ 
                            echo $comment->add_button_chairperson('Minute',$decision['Decision']);
                        }else{
                            echo $comment->list_comment('Minute',$decision['Decision']);
                        }
                    }else{
                        if(!empty($chairperson) || $permission['Minute approval']['Create']){
                            echo "<div>".$comment->add_form('Minute',$decision['Decision']).'</div><br/>';
                        }
                        echo $comment->list_comment('Minute',$decision['Decision']);
                    }
                ?>
            </td>
        <?php } ?>
    </tr>
    <tr class='minuteitem_actionrow'>
        <?php
        // see whether this is for info or have to take action
        $actionby = '';
        $list = '';
        $due = '';
        $new_userlist = isset($decision['Decision']['Userlist'][0]) ? $decision['Decision']['Userlist'][0] : 0;
        $new_grouplist = isset($decision['Decision']['Grouplist'][0]) ? $decision['Decision']['Grouplist'][0] : 0;
        
        if ( $new_userlist || $new_grouplist ) {
            is_array($new_userlist) ? $num_userlist = count($new_userlist) : $num_userlist = 0;
            is_array($new_grouplist) ? $num_grouplist = count($new_grouplist) : $num_grouplist = 0;
           
            $actionby = "<span class='actionby'>".__('Action By',true).":</span> ";
            
            // get the implementors
            if ( $num_userlist ) {
                $users = '';
                for ($i=0;$i<$num_userlist;$i++) {
                    if ($i < $num_userlist) {
                        $users.= $new_userlist[$i].', ';
                    }
                }
                if($num_grouplist ==0){
                    $users = trim($users,', ');
                }
                $list.= "<span class='impl'>$users</span> ";
            }
            
            if ( $num_grouplist ) {
                $groups = '';
                for ($i=0;$i<$num_grouplist;$i++) {
                    //if ($i < $num_grouplist) {
                        $groups.= $new_grouplist[$i].', ';
                    //}           
                }
                $groups = trim($groups,', ');
                $list.= "<span class='impl'>$groups</span> ";
            }
            
            // get due date
            if(date('Y-m-d',strtotime($decision['Decision']['deadline']))=='1970-01-01'){
                $due='';
            }else{
                $due = "<span class='due'>".__('Due',true).":</span> <span class='duedate'>".date(Configure::read('date_format'),strtotime($decision['Decision']['deadline']))."</span>";
            }
        } else {
            $due = "<span class='information'>".__('Information',true)."</span> ";
        }
        ?>
        <td width='30'>&nbsp;</td>
        <td width='10'>&nbsp;</td>
        <td width='10%'>&nbsp;</td>
        <td class='minuteitem_4'><?php echo $actionby;?></td>
        <td class='minuteitem_5'><?php echo $list; ?></td>
        <td class='minuteitem_6'>&nbsp;</td>
        <td class='minuteitem_7'><div class="tindakan"><?php echo $actionby;?><?php echo $list; ?></div><?php echo $due; ?></td>
    </tr>
    <?php
    if ( isset($report) != 1 ) { 
    ?>
    <tr>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td colspan='5' class="minutes_decisionlinks">
            <div class='arrow'>
                <?php
                    $decision_id = $decision['Decision']['id'];
                    if ( $arrows[$decision_id]['up'] == 1 ) { 
                        echo $html->link($html->image('icons/go-up.gif'),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'decisions','action'=>'promote2','id'=>$decision_id),array('escape'=>false));
                    } 
                    if ( $arrows[$decision_id]['down'] == 1 ) { 
                        //echo "<a href='../../../".$dcommittee['Committee']['short_name']."/decisions/demote2/".$decision_id."'><img src='".router::url('/img/icons/go-down.gif')."'/></a>";        
                        echo $html->link($html->image('icons/go-down.gif'),array('committee'=>$dcommittee['Committee']['short_name'],'controller'=>'decisions','action'=>'demote2','id'=>$decision_id),array('escape'=>false));
                    }               
                ?>
            </div>
            <div id='displayform_<?php echo $node;?>'>
            <?php echo $this->element('minutes/decision_links',array('node'=>$node,'meetingid'=>$meetingid,'id'=>$decision['Decision']['id'])); ?>
            </div>
        </td>
    </tr>
    <?php
    }
    ?>
</table>
